home *** CD-ROM | disk | FTP | other *** search
- /*•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
- /* ObjectData.h
- /*
- /* Object definitions for Cube, House, and Icosahedron.
- /*
- /* Author: Michael Chen, Human Interface Group / ATG
- /* Copyright © 1991-1993 Apple Computer, Inc. All rights reserved.
- /*
- /* Part of Virtual Sphere Sample Code Release v1.1
- /*•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••*/
-
- /*=================================================================================================
- /* Cube
- /*-------------------------------------------------------------------------------------------------*/
- #define kCubeWidth Long2Fix(200)
- #define kCubeDepth Long2Fix(200)
- #define kCubeHeight Long2Fix(200)
-
- /* Vertex array */
- static Point3D gCubeVertices[] =
- {
- { kCubeWidth/2, kCubeDepth/2, -kCubeHeight/2},
- { kCubeWidth/2, -kCubeDepth/2, -kCubeHeight/2},
- {-kCubeWidth/2, -kCubeDepth/2, -kCubeHeight/2},
- {-kCubeWidth/2, kCubeDepth/2, -kCubeHeight/2},
-
- { kCubeWidth/2, kCubeDepth/2, kCubeHeight/2},
- { kCubeWidth/2, -kCubeDepth/2, kCubeHeight/2},
- {-kCubeWidth/2, -kCubeDepth/2, kCubeHeight/2},
- {-kCubeWidth/2, kCubeDepth/2, kCubeHeight/2},
- };
-
- /* Color array */
- static RGBColor gCubeColors[] =
- {
- { 3659, 3901, 65535},
- { 4096, 4096, 4096},
- {65535, 12157, 3994},
- {65535, 35196, 5058},
- {65535, 61127, 5185},
- {38086, 44563, 55535},
- };
-
- /* Indices array into vertex array */
- static Integer gCubeVertexIndices[] =
- {
- 4, 7, 6, 5, /* front face */
- 0, 1, 2, 3, /* back face */
- 5, 6, 2, 1, /* bottom face */
- 4, 0, 3, 7, /* top face */
- 3, 2, 6, 7, /* left face */
- 1, 0, 4, 5, /* right face */
- };
-
- /* Description of each polygon:
- * Format: {# vertices, 1st index into Indices array, index into color array}
- */
- static NetPolygon gCubePolys[] =
- {
- {4, 0, 0}, /* front face */
- {4, 4, 1}, /* back face */
- {4, 8, 2}, /* bottom face */
- {4, 12, 3}, /* top face */
- {4, 16, 4}, /* left face */
- {4, 20, 5}, /* right face */
- };
-
- static PolygonNetData gCubeData =
- {
- sizeof (gCubePolys)/sizeof(NetPolygon), /* Polygon count */
- gCubePolys,
- sizeof (gCubeVertices)/sizeof(Point3D), /* size of vertex array */
- gCubeVertices,
- gCubeVertexIndices,
- gCubeColors,
- };
-
-
- /*=================================================================================================
- /* House
- /*-------------------------------------------------------------------------------------------------*/
- #define HOUSE_SCALE 5/4
- #define FLOOR Long2Fix (-75)*HOUSE_SCALE /* floor */
- #define WIDTH Long2Fix (180)*HOUSE_SCALE /* width of house (floor plan) */
- #define DEPTH Long2Fix (120)*HOUSE_SCALE /* depth of house (floor plan) */
- #define HEIGHT1 Long2Fix ( 45)*HOUSE_SCALE /* height of house to bottom of roof */
- #define HEIGHT2 Long2Fix (105)*HOUSE_SCALE /* height of house to top of roof */
- #define DOOR_WIDTH Long2Fix ( 30)*HOUSE_SCALE
- #define DOOR_HEIGHT Long2Fix (-15)*HOUSE_SCALE
- #define DEPTH_ROOF Long2Fix ( 30)*HOUSE_SCALE /* depth of top of roof */
-
- /* Color array */
- static Point3D gHouseVertices[] =
- {
- {-WIDTH/2, FLOOR, DEPTH/2}, /* 0 */
- { WIDTH/2, FLOOR, DEPTH/2},
- { WIDTH/2, HEIGHT1, DEPTH/2},
- {-WIDTH/2, HEIGHT1, DEPTH/2},
-
- {-WIDTH/2, FLOOR, -DEPTH/2}, /* 4 */
- {-WIDTH/2, HEIGHT1, -DEPTH/2},
- { WIDTH/2, HEIGHT1, -DEPTH/2},
- { WIDTH/2, FLOOR, -DEPTH/2},
-
- { WIDTH/2, HEIGHT1, -DEPTH/2}, /* 8 */
- { WIDTH/2, HEIGHT2, -DEPTH_ROOF/2},
- { WIDTH/2, HEIGHT2, DEPTH_ROOF/2},
- { WIDTH/2, HEIGHT1, DEPTH/2},
-
- {-WIDTH/2, HEIGHT1, DEPTH/2}, /* 12 */
- {-WIDTH/2, HEIGHT2, DEPTH_ROOF/2},
- {-WIDTH/2, HEIGHT2, -DEPTH_ROOF/2},
- {-WIDTH/2, HEIGHT1, -DEPTH/2},
-
- { WIDTH/2, HEIGHT2, DEPTH_ROOF/2}, /* 16 */
- {-WIDTH/2, HEIGHT2, DEPTH_ROOF/2},
- {-WIDTH/2, HEIGHT2, -DEPTH_ROOF/2},
- { WIDTH/2, HEIGHT2, -DEPTH_ROOF/2},
-
- {-DOOR_WIDTH/2, FLOOR, DEPTH/2}, /* 20 */
- { DOOR_WIDTH/2, FLOOR, DEPTH/2},
- { DOOR_WIDTH/2, DOOR_HEIGHT, DEPTH/2},
- {-DOOR_WIDTH/2, DOOR_HEIGHT, DEPTH/2},
- };
-
- #define frontFaceColor 0
- #define backFaceColor 1
- #define rightFaceColor 2
- #define leftFaceColor 3
- #define bottomFaceColor 4
- #define frontRoofColor 5
- #define backRoofColor 6
- #define topRoofColor 7
- #define doorFaceColor 8
-
- /* Color array */
- static RGBColor gHouseColors[] =
- {
- {0x0000,0xffff,0xffff},
- {0x9700,0x9700,0x9700},
- {0x1300,0x0600,0xc400},
- {0x0000,0x5500,0x0000},
- {0x6700,0x0000,0x0900},
- {0xffff,0xffff,0x0000},
- {0xad00,0x1e00,0x0001},
- {0xffff,0x4800,0x0000},
- {0x4000,0x4000,0x4000},
- };
-
- /* Indices array into vertex array */
- static Integer gHouseVertexIndices[] =
- {
- 0, 1, 2, 3, /* front face */
- 4, 5, 6, 7, /* back face */
- 1, 7, 8, 9, 10, 11, /* right face */
- 0, 12, 13, 14, 15, 4, /* left face */
- 0, 4, 7, 1, /* bottom face */
- 12, 11, 16, 17, /* front roof */
- 15, 18, 19, 8, /* back roof */
- 16, 19, 18, 17, /* top of roof */
- 20, 21, 22, 23, /* front door */
- };
-
- /* Description of each polygon:
- * Format: {# vertices, 1st index into Indices array, index into color array}
- */
- static NetPolygon gHousePolys[] =
- {
- {4, 0, frontFaceColor},
- {4, 4, backFaceColor},
- {6, 8, rightFaceColor},
- {6, 14, leftFaceColor},
- {4, 20, bottomFaceColor},
- {4, 24, frontRoofColor},
- {4, 28, backRoofColor},
- {4, 32, topRoofColor},
- {4, 36, doorFaceColor},
- };
-
- static PolygonNetData gHouseData =
- {
- sizeof (gHousePolys)/sizeof(NetPolygon), /* polygonCount */
- gHousePolys,
- sizeof (gHouseVertices)/sizeof(Point3D), /* sizeOfVertexArray */
- gHouseVertices,
- gHouseVertexIndices,
- gHouseColors,
- };
-
-
- /*=================================================================================================
- /* Icosahedron
- /*-------------------------------------------------------------------------------------------------*/
- #define kCubeWidth Long2Fix(200)
- #define kCubeDepth Long2Fix(200)
- #define kCubeHeight Long2Fix(200)
-
- /* Vertex array */
- static Point3D gIcosahedronVertices[] =
- {
- { 0, 0, 11010048},
- { 9847675, 0, 4923866},
- { 3043109, 9365692, 4923866},
- { -7966924, 5788335, 4923866},
- { -7966955, -5788293, 4923866},
- { 3043059, -9365708, 4923866},
- { 7966939, 5788314, -4923866},
- { -3043084, 9365700, -4923866},
- { -9847675, 26, -4923866},
- { -3043134, -9365684, -4923866},
- { 7966909, -5788356, -4923866},
- { 0, 0, -11010048},
- };
-
- /* Color array */
- static RGBColor gIcosahedronColors[] =
- {
- {0x0000, 0x0000, 0xffff}, /* 0 blueColor */
- {0x0000, 0xffff, 0x0000}, /* 1 greenColor */
- {0x0000, 0xffff, 0xffff}, /* 2 yellowColor */
- {0xffff, 0x0000, 0x0000}, /* 3 redColor */
- {0xffff, 0x0000, 0xffff}, /* 4 magentaColor */
- {0xffff, 0xffff, 0x0000}, /* 5 cyanColor */
- };
-
- /* Indices array into vertex array */
- static Integer gIcosahedronVertexIndices[] =
- {
- 0, 1, 2,
- 0, 2, 3,
- 0, 3, 4,
- 0, 4, 5,
- 0, 5, 1,
- 1, 6, 2,
- 2, 7, 3,
- 3, 8, 4,
- 4, 9, 5,
- 5, 10, 1,
- 1, 10, 6,
- 2, 6, 7,
- 3, 7, 8,
- 4, 8, 9,
- 5, 9, 10,
- 7, 6, 11,
- 8, 7, 11,
- 9, 8, 11,
- 10, 9, 11,
- 6, 10, 11,
- };
-
- /* Description of each polygon:
- * Format: {# vertices, 1st index into Indices array, index into color array}
- */
- static NetPolygon gIcosahedronPolys[] =
- {
- {3, 0, 3}, /* face 0 */
- {3, 3, 4}, /* face 1 */
- {3, 6, 1}, /* face 2 */
- {3, 9, 2}, /* face 3 */
- {3, 12, 5}, /* face 4 */
- {3, 15, 0}, /* face 5 */
- {3, 18, 2}, /* face 6 */
- {3, 21, 3}, /* face 7 */
- {3, 24, 4}, /* face 8 */
- {3, 27, 1}, /* face 9 */
- {3, 30, 2}, /* face 10 */
- {3, 33, 5}, /* face 11 */
- {3, 36, 0}, /* face 12 */
- {3, 39, 0}, /* face 13 */
- {3, 42, 3}, /* face 14 */
- {3, 45, 4}, /* face 15 */
- {3, 48, 1}, /* face 16 */
- {3, 51, 2}, /* face 17 */
- {3, 54, 5}, /* face 18 */
- {3, 57, 0}, /* face 19 */
- };
-
- static PolygonNetData gIcosahedronData =
- {
- sizeof (gIcosahedronPolys)/sizeof(NetPolygon), /* Polygon count */
- gIcosahedronPolys,
- sizeof (gIcosahedronVertices)/sizeof(Point3D), /* size of vertex array */
- gIcosahedronVertices,
- gIcosahedronVertexIndices,
- gIcosahedronColors,
- };
-
-
- #ifdef xxx
- {0.000000, 0.000000, 150.000000},
- {134.163920, 0.000000, 67.082356},
- {41.459067, 127.597426, 67.082356},
- {-108.540724, 78.859804, 67.082356},
- {-108.541142, -78.859228, 67.082356},
- {41.458390, -127.597646, 67.082356},
- {108.540933, 78.859516, -67.082356},
- {-41.458728, 127.597536, -67.082356},
- {-134.163920, 0.000356, -67.082356},
- {-41.459405, -127.597316, -67.082356},
- {108.540515, -78.860092, -67.082356},
- {0.000000, 0.000000, -150.000000},
- #endif